package com.gbx.ximalayating.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.gbx.ximalayating.R;

/**
 * SplashActivity跳到AdsActivity,如果三秒内没有点击图片，就跳转到MainActivity,如果点击了图片就跳转到AdsWebActivity
 * 点击返回再回到MainActivity中；
 */
public class AdsActivity extends AppCompatActivity {
    public static final String ADS_URL = "http://adse.ximalaya.com/ting/loading?appid=0&device=android&name=loading&network=wifi&operator=0&version=4.3.98";
    private ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ads);
        imageView = (ImageView) findViewById(R.id.imageView);
        new AdsThread().start();
    }

    //点击跳转到广告详情页
    public void click(View view) {
        Intent intent = new Intent(this, AdsWebActivity.class);
        startActivity(intent);
        finish();
    }

    //三秒后跳到MainActivity中，无论什么时候到会跳到Main
    private class AdsThread extends Thread {
        @Override
        public void run() {
            super.run();
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            Intent intent = new Intent(AdsActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }
}
